package com.iwinding.ladygg;

import android.os.Environment;
import android.text.TextUtils;

import java.io.File;

/**
 * Created by 82218 on 2017/9/5.
 */

public class ICaneFile {
    static final String ICANE = "iCane";
    static final String PIC = "image";
    static String SDCARD = Environment.getExternalStorageDirectory().getPath();
    static final String basePath = SDCARD.endsWith(File.separator) ? SDCARD + ICANE : SDCARD + File.separator + ICANE;
    static final String picPath = basePath.endsWith(File.separator) ? basePath + PIC : basePath + File.separator + PIC;

    public static void initICaneFolder() {
        initFolderPath(basePath);
        initFolderPath(picPath);
    }

    private static void initFolderPath(String path) {
        File pathFile = new File(path);
        if (!pathFile.exists()) {
            pathFile.mkdir();
        }
    }

    public static String getImagePath() {
        return picPath;
    }

    public static String getImageName(String name) {
        StringBuffer buffer = new StringBuffer(picPath).append(File.separator);
        if (!TextUtils.isEmpty(name)) {
            buffer.append(name);
        } else {
            buffer.append(System.currentTimeMillis()).append(".png");
        }
        return buffer.toString();
    }

}
